package ch.christianschweizer.epk.common.framework;

import java.sql.CallableStatement;
import java.sql.SQLException;

import oracle.jbo.JboException;
import oracle.jbo.Session;
import oracle.jbo.server.DBTransactionImpl;


public class ApplicationModuleImpl extends oracle.jbo.server.ApplicationModuleImpl {

    protected void prepareSession(Session session) {
        super.prepareSession(session);
        setUserLanguage("DE");
    }

    private void setUserLanguage(String language) {
        DBTransactionImpl transation = (DBTransactionImpl)getTransaction();
        CallableStatement statement = transation.createCallableStatement("BEGIN SET_APP_USER_LANG(?); END;", 0);
        try {
            statement.setString(1, language.toUpperCase());
            statement.execute();
        } catch (SQLException e) {
            throw new JboException(e);
        } finally {
            if (statement != null) {
                try {
                    statement.close();
                } catch (SQLException e) {
                    throw new JboException(e);
                }
            }
        }
    }

}
